package com.hello.system.service.impl;

import java.util.List;
import com.hello.common.core.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hello.system.mapper.TreeHoleEntriesMapper;
import com.hello.system.domain.TreeHoleEntries;
import com.hello.system.service.ITreeHoleEntriesService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;

/**
 * 树洞内容Service业务层处理
 * 
 * @author hello
 * @date 2025-05-15
 */
@Slf4j
@Service
@RequiredArgsConstructor
public class TreeHoleEntriesServiceImpl extends ServiceImpl<TreeHoleEntriesMapper, TreeHoleEntries> implements ITreeHoleEntriesService 
{
    private final TreeHoleEntriesMapper treeHoleEntriesMapper;

    /**
     * 查询树洞内容
     * 
     * @param entryId 树洞内容主键
     * @return 树洞内容
     */
    @Override
    public TreeHoleEntries selectTreeHoleEntriesByEntryId(Long entryId)
    {
        return treeHoleEntriesMapper.selectTreeHoleEntriesByEntryId(entryId);
    }

    /**
     * 查询树洞内容列表
     * 
     * @param treeHoleEntries 树洞内容
     * @return 树洞内容
     */
    @Override
    public List<TreeHoleEntries> selectTreeHoleEntriesList(TreeHoleEntries treeHoleEntries)
    {
        return treeHoleEntriesMapper.selectTreeHoleEntriesList(treeHoleEntries);
    }

    /**
     * 新增树洞内容
     * 
     * @param treeHoleEntries 树洞内容
     * @return 结果
     */
    @Override
    public int insertTreeHoleEntries(TreeHoleEntries treeHoleEntries)
    {
        treeHoleEntries.setCreateTime(DateUtils.getNowDate());
        return treeHoleEntriesMapper.insertTreeHoleEntries(treeHoleEntries);
    }

    /**
     * 修改树洞内容
     * 
     * @param treeHoleEntries 树洞内容
     * @return 结果
     */
    @Override
    public int updateTreeHoleEntries(TreeHoleEntries treeHoleEntries)
    {
        treeHoleEntries.setUpdateTime(DateUtils.getNowDate());
        return treeHoleEntriesMapper.updateTreeHoleEntries(treeHoleEntries);
    }


    /**
     * 批量删除树洞内容
     * 
     * @param entryIds 需要删除的树洞内容主键
     * @return 结果
     */
    @Override
    public int deleteTreeHoleEntriesByEntryIds(Long[] entryIds)
    {
        return treeHoleEntriesMapper.deleteTreeHoleEntriesByEntryIds(entryIds);
    }

    /**
     * 删除树洞内容信息
     * 
     * @param entryId 树洞内容主键
     * @return 结果
     */
    @Override
    public int deleteTreeHoleEntriesByEntryId(Long entryId)
    {
        return treeHoleEntriesMapper.deleteTreeHoleEntriesByEntryId(entryId);
    }
    
    /**
     * 给树洞内容点赞
     * 
     * @param entryId 树洞内容主键
     * @return 结果
     */
    @Override
    public int likeTreeHoleEntry(Long entryId)
    {
        return treeHoleEntriesMapper.incrementLikesCount(entryId);
    }
    
    /**
     * 取消树洞内容点赞
     * 
     * @param entryId 树洞内容主键
     * @return 结果
     */
    @Override
    public int unlikeTreeHoleEntry(Long entryId)
    {
        return treeHoleEntriesMapper.decrementLikesCount(entryId);
    }
    
    /**
     * 给树洞内容不喜欢
     * 
     * @param entryId 树洞内容主键
     * @return 结果
     */
    @Override
    public int dislikeTreeHoleEntry(Long entryId)
    {
        return treeHoleEntriesMapper.incrementDislikesCount(entryId);
    }
    
    /**
     * 取消树洞内容不喜欢
     * 
     * @param entryId 树洞内容主键
     * @return 结果
     */
    @Override
    public int undislikeTreeHoleEntry(Long entryId)
    {
        return treeHoleEntriesMapper.decrementDislikesCount(entryId);
    }
    
    /**
     * 增加树洞内容查看次数
     * 
     * @param entryId 树洞内容主键
     * @return 结果
     */
    @Override
    public int incrementViewsCount(Long entryId)
    {
        return treeHoleEntriesMapper.incrementViewsCount(entryId);
    }
}
